<template>
	<view>
		<view class="List">
			<view class="item" v-for="(item,i) in List" :key="i" @tap="edit(item)">
				<view class="item-left">
					<view class="item-title">
						<view class="item-block" v-if="item.mo == 'mo'">
							默认
						</view>
						<view class="item-top">
							{{ item.xiang }}
						</view>
					</view>
					<view class="item-content">
						<view class="item-name">
							{{ item.name }}
						</view>
						<view class="item-tel">
							{{ item.tel }}
						</view>
					</view>
				</view>
				<view class="item-right">
					<u-icon name="arrow-right" color="#e5e5e5" size="16"></u-icon>
				</view>
			</view>
			<view class="block">

			</view>
		</view>
		<view class="footer">
			<view class="footer-btn" @tap="add">
				添加地址
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				List: [],
				page: 1
			}
		},
		onShow() {
			this.GetList()
		},
		onPullDownRefresh() {
			this.page = 1
			this.GetList()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			this.page++
			this.GetList()
		},
		methods: {
			add() {
				uni.navigateTo({
					url: '/pages/address/add'
				})
			},
			chouse(item) {
				uni.$emit('address', item)
				uni.navigateBack()
			},
			GetList() {
				this.$http.Post('address/list', {

				}, (result) => {
					if (this.page == 1) {
						this.List = []
					}
					this.List = this.List.concat(result.data.data)
					console.log(this.List)
				})
			},
			edit(item) {
				uni.navigateTo({
					url: '/pages/address/indexEdit?item=' + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style>
	.List {
		width: 94%;
		margin: 20rpx auto;
	}

	.item {
		background-color: #fff;
		display: flex;
		align-items: center;
		padding: 20rpx;
		margin-bottom: 20rpx;
		border-radius: 8rpx;
	}

	.item-left {
		width: 90%;
	}

	.item-right {
		width: 10%;
		display: flex;
		justify-content: flex-end;
		align-items: center;
	}

	.item-title {
		font-weight: bold;
		display: flex;
		align-items: center;
	}

	.item-top {
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.item-block {
		display: flex;
		justify-content: center;
		width: 100rpx;
		font-size: 26rpx;
		font-weight: 100;
		margin-right: 15rpx;
		border-radius: 8rpx;
		background-color: #e7e7e7;
		font-size: 28rpx;
		color: #ff5502;
		padding: 5rpx 0rpx;
	}

	.item-tel {
		margin-left: 20rpx;
	}


	.item-content {
		margin-top: 20rpx;
		display: flex;
		align-items: center;
		color: #ccc;
		font-size: 28rpx;
	}

	.block {
		width: 100%;
		height: 150rpx;
	}

	.footer {
		position: fixed;
		bottom: 80rpx;
		height: 100rpx;
		width: 94%;
		margin-left: 3%;
	}

	.footer-btn {
		color: #fff;
		font-size: 28rpx;
		background-color: #ef5350;
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		border-radius: 999rpx;
	}
</style>